Assignemnt #65 and 63rd program
Code
///Name: Derrick Andreasen
///Period: 7
///Program name: 63rd Program
///File name: Sixt3Prog.java
///Date Finished:11/17/2015
import java.util.Scanner;
import java.util.Random;
public class Sixt3Prog
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
Random r = new Random();
int x = 1 + r.nextInt(10), overall=0;
System.out.println( "I have chosen a number between 1 and 10. try to guess it." );
System.out.print( "Your guess: " );
int entry = keyboard.nextInt();
System.out.println( "" );
while ( entry != x )
{
System.out.println( "\nSorry, That's wrong. try again. ");
System.out.print( "> " );
entry = keyboard.nextInt();
overall++;
}
if( entry == x )
{
System.out.println( "" );
System.out.println( "Great job. You got it." );
overall++;
System.out.println( "It only took you " + overall + " tries!" );
}
}
}
Picture of the output